package com.swyc.osschat.Test.LambdaTest.Controller;

import java.util.Arrays;

public class AnonymousTest {
//    public static void main(String[] args) {
//        StreamTestService test = new StreamTestService(){
//          @Override
//          public void call(){
//              System.out.print("张三说李四是傻子!");
//          }
//        };
//        test.call();
//    }

//    public static void main(String[] args) {
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("rum");
//            }
//        }).start();
//        new Thread(()-> System.out.println("run!ss")).start();
//    }

//    public static void main(String[] args) {
//        Runnable run = new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("kaixin!");
//            }
//        };
//        Runnable run2 = ()-> System.out.println("bukaixin!");
//        run.run();
//        run2.run();
//    }
    public static void main(String[] args) {
        String[] players = {"Rafael Nadal", "Novak Djokovic","Stanislas Wawrinka", "David Ferrer","Roger Federer", "Andy Murray","Tomas Berdych", "Juan Martin Del Potro","Richard Gasquet", "John Isner"};
        StringBuilder sb1 = new StringBuilder();
        Arrays.asList(players).forEach(sb1::append);
//        Arrays.sort(players, new Comparator<String>() {
//            @Override
//            public int compare(String s1, String s2) {
//                return (s1.compareTo(s2));
//            }
//        });
        /**lambda排序*/
        Arrays.sort(players,(String s1,String s2)->(s1.compareTo(s2)));
        StringBuilder sb2 = new StringBuilder();
        Arrays.asList(players).forEach(sb2::append);
        System.out.println("排序前："+sb1.toString());
        System.out.println("排序后："+sb2.toString());
    }
}
